const isEmpty = (rule, value, callback) => {
  if (!value) {
    return callback(new Error('必须填写'))
  } else {
    return callback()
  }
}
const checkCardNo = (rule, value, callback) => {
  // 身份证号
  const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  if (!value) {
    return callback(new Error('必须填写证件号码'))
  } else if (rule.card_type === '1' && !regIdCard.test(value)) {
    return callback(new Error('身份证号格式错误'))
  } else {
    return callback()
  }
  // 军官证或士兵证
  // const regOfficer = /^[a-zA-Z0-9]{7,21}$/
  // 港澳通行证
  // const regHK = /^[a-zA-Z0-9]{5,21}$/
  // if (!value) {
  //   return callback(new Error('必须填写证件号码'))
  // } else if (rule.card_type === '1' && !regIdCard.test(value)) {
  //   return callback(new Error('身份证号错误'))
  // } else if (rule.card_type === '2' && !regOfficer.test(value)) {
  //   return callback(new Error('军官证号错误'))
  // } else if (rule.card_type === '4' && !regHK.test(value)) {
  //   return callback(new Error('港澳通行证号错误'))
  // } else {
  //   return callback()
  // }
}
const checkCity = (rule, value, callback) => {
  console.log(rule, 'rulerulerule')
  if (rule.no_check) {
    return callback()
  } else if (!value) {
    return callback(new Error('必须填写'))
  } else {
    return callback()
  }
}
// const checkMobile = (rule, value, callback) => {
//   console.log(value)
//   const regIdCard = /^1[3456789]\d{9}$/
//   if (!value) {
//     return callback(new Error('必须填写'))
//   } else if (value.length === 11 && !regIdCard.test(value)) {
//     return callback(new Error('手机号格式错误'))
//   } else {
//     return callback()
//   }
// }

export default {
  formData: {
    curStateList: [
      // [ { id: '1', name: '居家留观' }, { id: '2', name: '集中留观' } ],
      [ { id: '1', name: '居家留观' } ],
      [ { id: '4', name: '集中安置点' } ]
    ],
    occupationList: [
      { id: 1, name: '国家机关,党群组织' },
      { id: 2, name: '企业,事业单位负责人' },
      { id: 3, name: '专业技术人员' },
      { id: 4, name: '办事人员和有关人员' },
      { id: 5, name: '商业,服务业人员' },
      { id: 6, name: '农,林,牧,渔,水利业生产人员' },
      { id: 7, name: '生产,运输设备操作及有关人员' },
      { id: 8, name: '军人' },
      { id: 9, name: '退休' },
      { id: 10, name: '学生' },
      { id: 11, name: '其他' }
    ],
    focusPlaceList: [
      { id: 1, area: '市本级', name: '锦江之星（奉天街店）' },
      { id: 2, area: '和平区', name: '沈阳饭店' },
      { id: 3, area: '沈河区', name: '如家快捷酒店（五爱市场风雨坛街店）' },
      { id: 4, area: '铁西区', name: '宜必思酒店（沈阳铁西店）' },
      { id: 5, area: '铁西区', name: '锦江之星（经济技术开发区店）' },
      { id: 6, area: '皇姑区', name: '贝壳酒店' },
      { id: 7, area: '大东区', name: '欧园会议中心' },
      { id: 8, area: '浑南区', name: '麒麟商务宾馆' },
      { id: 9, area: '于洪区', name: '喜乐汇酒店' },
      { id: 10, area: '沈北新区', name: '华冠宾馆' },
      { id: 11, area: '苏家屯', name: '沈阳国际展览中心管理有限公司会议中心' },
      { id: 12, area: '辽中', name: '辽中区社会福利院及区中心敬老院（在同一院内）' },
      { id: 13, area: '新民', name: '新民市潢南宾馆' },
      { id: 14, area: '康平', name: '卧龙湖假日酒店' },
      { id: 15, area: '法库', name: '柏悦智选精品轻奢宾馆' }
    ]
  },
  ruleValidate: {
    name: [{ required: true, message: '必须填写', trigger: 'blur' }],
    card_no: [{ required: true, validator: checkCardNo, trigger: 'blur', card_type: '1' }],
    tel: [{ required: true, message: '必须填写', trigger: 'blur' }],
    occupation: [{ required: true, message: '必须填写', trigger: 'blur' }],
    area1: [{ validator: isEmpty, trigger: 'change' }],
    area2: [{ validator: isEmpty, trigger: 'change' }],
    area3: [{ validator: isEmpty, trigger: 'change' }],
    area4: [{ required: true, message: '必须填写', trigger: 'blur' }],
    area5: [{ required: true, message: '必须填写', trigger: 'blur' }],
    address: [{ validator: isEmpty, message: '必须填写', trigger: 'blur' }],
    arrive_time: [{ validator: isEmpty, message: '必须填写', trigger: 'blur' }],
    arrive_type: [{ validator: isEmpty, trigger: 'change' }],
    out_time: [{ validator: isEmpty, message: '必须填写', trigger: 'blur' }],
    out_type: [{ validator: isEmpty, trigger: 'change' }],
    arrive_type_remark: [{ required: true, message: '必须填写', trigger: 'blur' }],
    out_type_remark: [{ required: true, message: '必须填写', trigger: 'blur' }],
    province1: [{ validator: isEmpty, trigger: 'change' }],
    city1: [{ validator: checkCity, trigger: 'change' }],
    province2: [{ validator: isEmpty, trigger: 'change' }],
    city2: [{ validator: checkCity, trigger: 'change' }],
    protect_tel: [{ required: true, message: '必须填写', trigger: 'blur' }],
    focus_place: [{ validator: isEmpty, trigger: 'change' }],
    user_type: [{ validator: isEmpty, trigger: 'change' }]
  }
}
